<?php

class Core_Table_Promotion_Concessions extends Kd_Data_Table {

    private $_relationTable = '{t}promotion_concessions_poi';

    public function __construct() {
        parent::__construct();
    }

    public function insertPoiRelation($concessionsId, array $poiIds, $transaction = NULL) {
        $insert = Kd_Data_Factory::getInsertDcl()
                        ->into($this->_relationTable)
                        ->value('concessions_id', $concessionsId)
                        ->value('poi_id', ':poiId:s')
                        ->toSql();
        $driver = $this->getDbDriver($transaction);
        foreach ($poiIds as $poiId) {
            $driver->setSql($insert, array('poiId' => $poiId))->execute();
        }
    }

    public function deletePoiRelation($concessionsId, $transaction = NULL) {
        Kd_Data_Factory::getDeleteDcl()
                ->from($this->_relationTable)
                ->where()->eq('concessions_id', $concessionsId)->closest()
                ->setDbDriver($this->getDbDriver($transaction))
                ->execute();
    }
}